package com.zr.controller;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import com.zr.model.Customer;
import com.zr.service.QrmmService;
import com.zr.service.TjsqService;
import com.zr.serviceimp.QrmimaServiceimpl;
import com.zr.serviceimp.TjddServiceImpl;
import com.zr.serviceimp.TjsqServiceimpl;

public class SqkdlyController extends HttpServlet{
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp)
		throws ServletException, IOException {
	// TODO Auto-generated method stub
	doPost(req, resp);
}
@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		// TODO Auto-generated method stub
		String psd=req.getParameter("Psd");
		HttpSession session=req.getSession();
		Customer cs=(Customer) session.getAttribute("customerly");
		int uid=cs.getUid();
		QrmmService qs=new QrmimaServiceimpl();
		TjsqService ts=new TjsqServiceimpl();
		boolean flag= qs.checknub(uid, psd);
		PrintWriter pw=resp.getWriter();
		if(flag){
			if(ts.tjsq(uid)){
				pw.write("1");
				pw.flush();
				pw.close();
			}
			else{
				pw.write("2");
				pw.flush();
				pw.close();
			}
		}else{
			pw.write("3");
			pw.flush();
			pw.close();
			
		}
		
	}
}
